package com.baitai.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.baitai.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baitai.common.annotation.Log;
import com.baitai.common.core.controller.BaseController;
import com.baitai.common.core.domain.AjaxResult;
import com.baitai.common.enums.BusinessType;
import com.baitai.system.domain.SignInRule;
import com.baitai.system.service.ISignInRuleService;
import com.baitai.common.utils.poi.ExcelUtil;
import com.baitai.common.core.page.TableDataInfo;

/**
 * signInRuleController
 * 
 * @author ruoyi
 * @date 2024-07-10
 */
@RestController
@RequestMapping("/system/signInRule")
public class SignInRuleController extends BaseController
{
    @Autowired
    private ISignInRuleService signInRuleService;

    /**
     * 查询signInRule列表
     */
    @PreAuthorize("@ss.hasPermi('system:signInRule:list')")
    @GetMapping("/list")
    public TableDataInfo list(SignInRule signInRule)
    {
        startPage();
        List<SignInRule> list = signInRuleService.selectSignInRuleList(signInRule);
        return getDataTable(list);
    }

    /**
     * 导出signInRule列表
     */
    @PreAuthorize("@ss.hasPermi('system:signInRule:export')")
    @Log(title = "signInRule", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SignInRule signInRule)
    {
        List<SignInRule> list = signInRuleService.selectSignInRuleList(signInRule);
        ExcelUtil<SignInRule> util = new ExcelUtil<SignInRule>(SignInRule.class);
        util.exportExcel(response, list, "signInRule数据");
    }

    /**
     * 获取signInRule详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:signInRule:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(signInRuleService.selectSignInRuleById(id));
    }

    /**
     * 新增signInRule
     */
    @PreAuthorize("@ss.hasPermi('system:signInRule:add')")
    @Log(title = "signInRule", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SignInRule signInRule)
    {
        return toAjax(signInRuleService.insertSignInRule(signInRule));
    }

    /**
     * 修改signInRule
     */
    @PreAuthorize("@ss.hasPermi('system:signInRule:edit')")
    @Log(title = "signInRule", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SignInRule signInRule)
    {
        return toAjax(signInRuleService.updateSignInRule(signInRule));
    }

    /**
     * 删除signInRule
     */
    @PreAuthorize("@ss.hasPermi('system:signInRule:remove')")
    @Log(title = "signInRule", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(signInRuleService.deleteSignInRuleByIds(ids));
    }

    /**
     * 获取signInRule详细信息
     */
    @GetMapping(value = "/querySignInfo")
    public AjaxResult querySignInfo()
    {
        return success(signInRuleService.querySignInfo());
    }


    /**
     * 获取signInRule详细信息
     */
    @GetMapping(value = "/querySignCount")
    public AjaxResult querySignCount(String isFinish)
    {
        return success(signInRuleService.querySignCount(SecurityUtils.getUserId(),isFinish));
    }
}
